<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php

require 'rcon.inc.php';

$pwd = $_REQUEST['pwd'];
if ($pwd) {
	$rcon = new RconClient();
	try {
		$scope_demo = 'sdfdsf';
		$header = $rcon->connect('127.0.0.1', 4711);
		$result = $rcon->invoke('login ' . pwd);
		if (beginsWith($result, 'Authentication success')) {
			$_SESSION['rcon'] = $rcon;
	
			header("Location: index.php"); // Redirect browser
			
			// Make sure that code below does not get executed when we redirect.
			exit;
		}
	} catch (Exception $e) {
		echo $e;
	}
	echo $scope_demo;
}
?>
<html>
    <head>
        <title>login</title>
    </head>
    <body>
        <form method="post">
            <input type="password" name="pwd"/><input type="submit" value="login"/>
        </form>
    </body>
</html>